import type { AppRegistrationDto } from "@/types/userDetails";
import { http } from "@/utils/http";
import type { RegistrationStatusVo, Registration } from "@/types/userDetails";

// 获取预约信息
export const getAppointmentsBypatientId = (data: RegistrationStatusVo) => {
    return http({
        method: "POST",
        url: "/doctor/registration/getAppointmentsBypatientId",
        data
    }).then((response) => {
        if (response.code === 200) {
            return response.data as Registration[]; // 假设返回的数据是预约的列表
        } else {
            console.error('获取预约信息失败:', response);
            return [];
        }
    });
};

// 获取病人信息并添加预约
export const getAppRegistrationDto = (data: AppRegistrationDto) => {
    return http({
        method: "POST",
        url: "/doctor/registration/addAppRegistration",
        data
    }).then((response) => {
        if (response.code === 200) {
            return response.data; // 假设后端返回的数据在 response.data
        } else {
            console.error('挂号失败:', response); // 输出更多错误信息
        }
    });
};

// 删除预约
export const deleteRegistrationById = (registrationId: string) => {
    return http({
        method: "DELETE",
        url: `/doctor/registration/deleteRegistration/${registrationId}`,
    }).then((response) => {
        if (response.code === 200) {
            return response.data; // 假设删除成功后返回的数据在 response.data
        } else {
            console.error('取消预约失败:', response); // 输出更多错误信息
        }
    });
};
